Here is an explanation for why the coordinates of the point A are A= (2*a-1,1):

The 1 in A= (___, 1) is because the second numebr (y) tells how high the point is.
The first number must depend on the slider called a. The slider changes from 0 to 1. In order to make the point A move in a constant rate we must use a "linear formula" using the slider a. so A=(m*a+b,1) where m and b are not known yet. Let us assume that when a=0 m*a+b=-1 (the left corner of the square) so we get 0*a +b = -1 so b=-1 and then a=1 we get the right corner of the square (m*1-1 = 1 so m=2) so as a result we get A=(2*a -1,1).
In the same way B=(1 - 2*a,-1) Since moves in the opposite direction. Please try to explain it to yourself in a similar way as the above explanation.